package com.lqk.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author lqk
 * @date 2021/12/9 19:33
 */
public class InfoCollegeIterator implements Iterator {

    // 信息工程学院是以List方式存放系
    List<Department> departmentList;
    int index = -1; // 索引

    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    // 判断List中还有没有下一个元素
    @Override
    public boolean hasNext() {
        if (index >= departmentList.size()-1){
            return false;
        }else {
            index += 1;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentList.get(index);
    }

    @Override
    public void remove() {

    }
}
